import {
  Controller,
  Post,
  Body,
  UseGuards,
  Request,
  Get,
} from '@nestjs/common';
import { ApiOperation, ApiTags, ApiResponse } from '@nestjs/swagger';
import { WebsiteService } from './website.service';
import { Website } from './entities/website.entity';
import { websiteId } from './enums/const';
import { WebsiteDto } from './dto/website.dto';

@ApiTags('官网')
@Controller('website')
export class WebsiteController {
  constructor(private readonly websiteService: WebsiteService) {}
  @Post()
  @ApiOperation({ summary: '创建官网信息', description: '创建官网基本信息' })
  @ApiResponse({ status: 200, description: '创建成功', type: Website })
  createWebsiteInfo(@Body() createWebsiteDto: WebsiteDto): Promise<Website> {
    createWebsiteDto.id = websiteId.id;    
    return this.websiteService.create(createWebsiteDto);
  }

  @Get()
  @ApiOperation({ summary: '获取官网信息', description: '获取官网基本信息' })
  @ApiResponse({ status: 200, description: '获取成功', type: [Website] })
  findWebsiteInfo(): Promise<Website> {
    return this.websiteService.findOrcreated(websiteId.id);
  }
}
